import { defineConfig } from 'vite'
import vue3Plugin from '@vitejs/plugin-vue'
import vue3Jsx from '@vitejs/plugin-vue-jsx'
// import babel from 'vite-plugin-babel'
import useGod from './babelPlugins/useGod'
// import mdLoader from "./vite_plugins/mdLoader.js";
// import vritualModuleLoader from "./vite_plugins/vritualModule.js";
import langJsx from './vite_plugins/langJsx.js'
// import langJsx222 from './vite_plugins/langJsx2.js'
// import langJsx333 from './vite_plugins/langJsx3.js'

export default defineConfig({
  plugins: [
    vue3Jsx(),
    vue3Plugin(),
    langJsx()
  ],
  build: {
    rollupOptions: {
      output: {
        manualChunks(id) {
          if (id.includes('node_modules')) {
            return id.toString().split('node_modules/')[1].split('/')[0].toString()
          }
        },
        entryFileNames: 'js/[name].[hash].js',
        assetFileNames: '[ext]/[name].[hash].[ext]',
        chunkFileNames: chunkInfo => {
          const facadeModuleId = chunkInfo.facadeModuleId ? chunkInfo.facadeModuleId.split('/') : []
          const fileName = facadeModuleId[facadeModuleId.length - 2] || '[name]'
          return `js/${fileName}/[name].[hash].js`
        }
      }
    }
  },
})
